package top.xinsix.est.controller;

import top.xinsix.est.pojo.Users;
import top.xinsix.est.tools.Result;
import top.xinsix.est.tools.ResultUtils;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
@ApiModel("测试控制")       //描述实体
public class TestController {
    //value接口说明  httpMethod：请求方式  protocols：协议类型
    //notes：详细说明  produces：接口返回值的具体类型
    //response：响应类型，接口返回的对象
    @ApiOperation(value = "测试",httpMethod = "GET",produces = "HTTP",response = Result.class,
            protocols = "application/json",notes = "主要测试swagger使用")
    @GetMapping("/test")
    public Result test(){
        return ResultUtils.returnSuccess();
    }


    @ApiOperation(value = "登录",httpMethod = "POST",produces = "HTTP",response = Result.class,
            protocols = "application/json",notes = "使用账号密码进行登录")
    @PostMapping("/login")
    public Result login(@ApiParam(required = true,name="userName",value = "用户名") String userName,
                        @ApiParam(required = true,name="pwd",value = "密码")String pwd){
        if ("Felix".equals(userName)&&"Felix".equals(pwd)){
            return ResultUtils.returnSuccess();
        }else{
            return ResultUtils.returnFail();
        }
    }


    @ApiOperation(value = "登录",httpMethod = "POST",produces = "HTTP",response = Result.class,
            protocols = "application/json",notes = "使用账号密码进行登录")
   /* @ApiImplicitParam(name="users",value = "用户对象",required = true,dataType = "Users")*/
    @ApiImplicitParams({@ApiImplicitParam(name="users",value = "用户对象",required = true,dataType = "Users")})
    @PostMapping("/register")
    public Result register(Users users){
        if (users!=null){
            return ResultUtils.returnSuccess();
        }else{
            return ResultUtils.returnFail();
        }
    }
}
